package com.hyts.dbutils.bean.dbutils;

import com.hyts.dbutils.bean.jdbc.JdbcConnectionBean;
import com.hyts.dbutils.config.ExecutorType;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.dbutils.AbstractQueryRunner;

import javax.sql.DataSource;

/**
 * project-name:coffice-toolbox
 * package-name:com.hyts.dbopera.dbutils.bean
 * author:Libo/Alex
 * create-date:2019-06-23 21:03
 * copyright:libo-hyts-github
 * email:libo2dev@aliyun.com
 * description:此类主要用于: dbutils 工具类服务的数据对象
 */
//@Builder
//@Data
public class DbConnectionBean extends JdbcConnectionBean {

    /**
     * 选择抽象的查询runner执行器-便于选择不同的queryRunner对象
     * 同步或者异步处理
     */
    @Getter
    @Setter
    private AbstractQueryRunner queryRunner;

    /**
     * 执行同步或者异步功能实现
     */
    @Getter
    @Setter
    private ExecutorType executorType;

    /**
     * 构造器
     * @param url
     * @param user
     * @param password
     * @param driverClass
     * @param executorType
     */
    public DbConnectionBean(String url, String user, String password, String driverClass, ExecutorType executorType) {
        super(url, user, password, driverClass);
        this.executorType = executorType;
    }

    /**
     * 构造器
     * @param url
     * @param user
     * @param password
     * @param driverClass
     */
    public DbConnectionBean(String url, String user, String password, String driverClass) {
        super(url, user, password, driverClass);
        this.executorType = ExecutorType.SYNC;
    }

    /**
     * 构造器
     * @param dataSource
     * @param executorType
     */
    public DbConnectionBean(DataSource dataSource, ExecutorType executorType) {
        super(dataSource);
        this.queryRunner = queryRunner;
        this.executorType = executorType;
    }

    /**
     * 构造器
     * @param dataSource
     */
    public DbConnectionBean(DataSource dataSource) {
        super(dataSource);
        this.queryRunner = queryRunner;
        this.executorType = ExecutorType.SYNC;
    }

}
